<?php
class InstallerPage extends BasePage{
	public function onLoad($param){
		parent::onLoad($param);
		
		$applicationXml = new TXmlDocument();
		$applicationXml->loadFromFile("protected/application.xml");
		
		// getting the application.xml modules section
		$modules = $applicationXml->getElementByTagName("modules");
		
		// creating a new module for a new connection string
		$module = new TXmlElement("module");
		
		// setting the class and id of the new connection string module
		$module->setAttribute("class","System.Data.TDataSourceConfig");
		$module->setAttribute("id","BackupDBConnection");
		
		// creating the database node for the new connection string module
		$database = new TXmlElement("database");
		$database->setAttribute("ConnectionString","mysql:host=localhost;dbname=codemaker");
		$database->setAttribute("Username","root");
		$database->setAttribute("Password","123");
		
		// adding the database node to the connection string module
		$module->Elements[] = $database;
		// adding the new connection string module to the modeles of applciation.xml
		$modules->Elements[] = $module; 
		
		// writing the new application.xml into another file
		$applicationXml->saveToFile("protected/application.xml");
	}
}
?>